package com.example.devsa_platform.pojo.doc;

import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import org.apache.commons.csv.CSVRecord;
import org.springframework.data.elasticsearch.annotations.Document;
import org.springframework.data.elasticsearch.annotations.Field;

import java.util.Objects;

@Data
@AllArgsConstructor
@NoArgsConstructor
@JsonIgnoreProperties(ignoreUnknown = true)
@Document(indexName = "artificial_intelligence",createIndex = false)
public class ArtificialIntelligenceDoc {

    @Field(name ="ai_select")
    private String aiSelect;
    @Field(name ="ai_sent")
    private String aiSent;
    @Field(name ="ai_acc")
    private String aiAcc;
    @Field(name ="ai_ben")
    private String aiBen;
    @Field(name ="ai_tool_interest_in_use")
    private String aiToolInterestInUse;
    @Field(name = "ai_tool_currently_using")
    private String aiToolCurrentlyUsing;
    @Field(name = "ai_tool_not_interested_in_using")
    private String aiToolNotInterestedInUsing;
    @Field(name ="ai_next_very_different")
    private String aiNextVeryDifferent;
    @Field(name ="ai_next_neither_different_nor_similar")
    private String aiNextNeitherDifferentNorSimilar;
    @Field(name = "ai_next_somewhat_similar")
    private String aiNextSomewhatSimilar;
    @Field(name ="ai_next_very_similar")
    private String aiNextVerySimilar;
    @Field(name = "ai_next_somewhat_different")
    private String aiNextSomewhatDifferent;

    public ArtificialIntelligenceDoc(CSVRecord record) {
        this.aiSelect = getValueOrDefault(record.get("AISelect"));
        this.aiSent = getValueOrDefault(record.get("AISent"));
        this.aiAcc = getValueOrDefault(record.get("AIAcc"));
        this.aiBen = getValueOrDefault(record.get("AIBen"));
        this.aiToolInterestInUse = getValueOrDefault(record.get("AIToolInterested in Using"));
        this.aiToolCurrentlyUsing = getValueOrDefault(record.get("AIToolCurrently Using"));
        this.aiToolNotInterestedInUsing = getValueOrDefault(record.get("AIToolNot interested in Using"));
        this.aiNextVeryDifferent = getValueOrDefault(record.get("AINextVery different"));
        this.aiNextNeitherDifferentNorSimilar = getValueOrDefault(record.get("AINextNeither different nor similar"));
        this.aiNextSomewhatSimilar = getValueOrDefault(record.get("AINextSomewhat similar"));
        this.aiNextVerySimilar = getValueOrDefault(record.get("AINextVery similar"));
        this.aiNextSomewhatDifferent = getValueOrDefault(record.get("AINextSomewhat different"));


    }

    private String getValueOrDefault(String value) {
        return Objects.equals(value, "NA") ? "No Answer" : value;
    }

}
